/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * EstoqForm.java
 *
 * Created on 29/11/2009, 23:16:25
 */

package sigbar.view;

import sigbar.access.BDInterface;
import java.util.Vector;

/**
 *
 * @author Hudson
 */
public class EstoqForm extends javax.swing.JPanel {

    CadastroForn cadastro;
    ProcFornecedor procurarforn;
    ProcCompra proccompra;
    EdicaoProd CadRemProd;
    BDInterface bcon;

    public BDInterface getBcon() {
        return bcon;
    }

    public void setBcon(BDInterface bcon) {
        this.bcon = bcon;
    }

    /** Creates new form EstoqForm */
    public EstoqForm(BDInterface bcon) {
        initComponents();
        setBcon(bcon);
        init();
    }

    private void init() {
        Vector<Vector<String>> v = bcon.buscarProdutos();
        int i = 0;
        for (Vector<String> vector : v) {
            tableEstoque.getModel().setValueAt(vector.get(0), 0, i);
            tableEstoque.getModel().setValueAt(vector.get(1), 1, i);
            tableEstoque.getModel().setValueAt(vector.get(2), 2, i);
            tableEstoque.getModel().setValueAt(vector.get(3), 3, i);
            tableEstoque.getModel().setValueAt(vector.get(4), 4, i);
            i++;
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        buttonCadFornecedor = new javax.swing.JButton();
        buttonProcFornecedor = new javax.swing.JButton();
        buttonProcCompra = new javax.swing.JButton();
        buttonEditProd = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tableEstoque = new javax.swing.JTable();

        buttonCadFornecedor.setText("Cadastrar Fornecedor");
        buttonCadFornecedor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonCadFornecedorActionPerformed(evt);
            }
        });

        buttonProcFornecedor.setText("Procurar Fornecedor");
        buttonProcFornecedor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonProcFornecedorActionPerformed(evt);
            }
        });

        buttonProcCompra.setText("Processar Compra");
        buttonProcCompra.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonProcCompraActionPerformed(evt);
            }
        });

        buttonEditProd.setText("Editar Produtos");
        buttonEditProd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonEditProdActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(buttonEditProd, javax.swing.GroupLayout.DEFAULT_SIZE, 177, Short.MAX_VALUE)
            .addComponent(buttonProcCompra, javax.swing.GroupLayout.DEFAULT_SIZE, 177, Short.MAX_VALUE)
            .addComponent(buttonProcFornecedor, javax.swing.GroupLayout.DEFAULT_SIZE, 177, Short.MAX_VALUE)
            .addComponent(buttonCadFornecedor, javax.swing.GroupLayout.DEFAULT_SIZE, 177, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(buttonCadFornecedor)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buttonProcFornecedor)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buttonProcCompra)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buttonEditProd)
                .addContainerGap())
        );

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel1.setText("Estoque Atual");

        tableEstoque.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null}
            },
            new String [] {
                "Produto", "Valor de Compra", "Limite", "Valor Venda", "Quantidade"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.Object.class, java.lang.Integer.class, java.lang.Object.class, java.lang.Integer.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane1.setViewportView(tableEstoque);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 597, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addGap(286, 286, 286)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 333, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void buttonCadFornecedorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCadFornecedorActionPerformed
        cadastro = new CadastroForn(null,true,getBcon());
        cadastro.setVisible(true);
}//GEN-LAST:event_buttonCadFornecedorActionPerformed

    private void buttonProcFornecedorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonProcFornecedorActionPerformed
        procurarforn = new ProcFornecedor(null,true);
        procurarforn.setVisible(true);
    }//GEN-LAST:event_buttonProcFornecedorActionPerformed

    private void buttonProcCompraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonProcCompraActionPerformed
        proccompra = new ProcCompra(null,true);
        proccompra.setVisible(true);
    }//GEN-LAST:event_buttonProcCompraActionPerformed

    private void buttonEditProdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonEditProdActionPerformed
        CadRemProd = new EdicaoProd(null,true,getBcon());
        CadRemProd.setVisible(true);
}//GEN-LAST:event_buttonEditProdActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton buttonCadFornecedor;
    private javax.swing.JButton buttonEditProd;
    private javax.swing.JButton buttonProcCompra;
    private javax.swing.JButton buttonProcFornecedor;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable tableEstoque;
    // End of variables declaration//GEN-END:variables

}
